package com.prs.crm.action.purchase.flow;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.ui.PaginationSupport;

import com.prs.crm.action.FlowAction;
import com.prs.crm.annotation.Clew;
import com.prs.crm.context.AppContext;
import com.prs.crm.domain.purchase.PurchaseOrder;
import com.prs.crm.domain.sale.SalesShipping;
import com.prs.crm.service.purchase.PurchaseOrderService;
import com.prs.crm.service.sale.SalesShippingService;

@SuppressWarnings("serial")
public class PurchaseOrderFlowAction extends FlowAction<PurchaseOrder> {

	private PurchaseOrder purchaseOrder;
	private PurchaseOrderService purchaseOrderService;	
	private PaginationSupport pagination;
	
	
	@Action("listPurchaseOrderFlow")
	public String listPurchaseOrderFlow() {
		pagination = this.getPaginationHelper().prepare(pagination);
		pagination = this.getPurchaseOrderService().listFlowTask(PurchaseOrder.class, pagination, AppContext.getAccountContext().currentUser());
		return SUCCESS;
	}
	
	@Action("editPurchaseOrderFlow")
	public String editPurchaseOrderFlow() {
		this.displayEndNodes();		
		return SUCCESS;
	}
	
	@Clew(results={"success"})
	@Action(value="submitPurchaseOrderFlow",results={@Result(name="success",type="redirect",location="listPurchaseOrderFlow")})
	public String submitPurchaseOrderFlow() {
		
		this.getPurchaseOrderService().execute(this.getNode(), this.getDetail(), purchaseOrder, AppContext.getAccountContext().currentUser());
	
		this.setPrompt("提交成功");
		return SUCCESS;
	}

	

	public PurchaseOrder getPurchaseOrder() {
		return purchaseOrder;
	}

	public void setPurchaseOrder(PurchaseOrder purchaseOrder) {
		this.purchaseOrder = purchaseOrder;
	}

	public PurchaseOrderService getPurchaseOrderService() {
		return purchaseOrderService;
	}

	public void setPurchaseOrderService(PurchaseOrderService purchaseOrderService) {
		this.purchaseOrderService = purchaseOrderService;
	}

	public PaginationSupport getPagination() {
		return pagination;
	}

	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}

}
